package com.ansion.commonchat.contact.adapter;

import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;

import com.ansion.adapter.ITurboItem;
import com.ansion.adapter.TurboAdapter;
import com.ansion.baseui.base.view.ParagraphTextView;
import com.ansion.commonchat.R;
import com.ansion.commonchat.contact.bean.ContactHeaderBean;
import com.ansion.view.pin_view.PinnedHeaderAdapter;


/**
 * 联系人 header A，B，C，D，……，Z，#
 */
public class ContactHeaderItem implements ITurboItem<ContactHeaderItem.VH> {

    @Override
    public int getType() {
        return PinnedHeaderAdapter.PIN_TYPE;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.contact_item_header;
    }

    @NonNull
    @Override
    public VH getViewHolder(View v) {
        return new VH(v);
    }

    class VH extends TurboAdapter.ViewHolder<ContactHeaderBean> {

        ParagraphTextView mTvTitle;

        public VH(View itemView) {
            super(itemView);
            mTvTitle = itemView.findViewById(R.id.contact_item_header_text);
        }

        @Override
        public void bindView(ContactHeaderBean bean, int position) {
            String cateTitle = bean.cateTitle;
            if (!TextUtils.isEmpty(cateTitle)) {
                mTvTitle.setText(cateTitle.toUpperCase());
            }
        }
    }
}
